#include "Welcome.h"
#include <QPixmap>
#include <QDebug>

Welcome::Welcome(Widget* p,QWidget *parent) : QDialog(parent)
{
    gameWidget = p;
    this->setWindowTitle("Tank 2022");
    WelBackGround.setPixmap(QPixmap(":/map_image/element/WelcomeBackGround.jpg"));
    this->setWindowIcon(QIcon(":/map_image/element/TankICO.ico"));
    this->setCursor(QCursor(QPixmap(":/map_image/element/Cursor.png")));
    WelBackGround.setScale(0.4);
    qDebug()<<WelBackGround.pixmap().size()*0.4;
    MyScene.addItem(&WelBackGround);
    WelcomeView.setScene(&MyScene);
    WelBackGround.show();
    WelcomeView.setParent(this);
    WelcomeView.resize(WelBackGround.pixmap().size()*0.4);
    this->setFixedSize(WelBackGround.pixmap().size()*0.4);
    qDebug()<<"THIS:"<<WelcomeView.size();
    for(int i=0;i<3;i++)
    {
        btn[i].setParent(this);
    }
    btn[0].setText("开始游戏");
    btn[1].setText("游戏设置");
    btn[2].setText("退出游戏");
    label = new QLabel(this);
    label->setText("Tank 2022");
    label->setFont(QFont("Tempus Sans ITC",100,true,false));
    label->setStyleSheet("QLabel{color:brown}");
    label->move(40,200);
    label->resize(900,300);
    for(int i=0;i<3;i++)
    {
        btn[i].resize(300,200);
        btn[i].setFont(QFont("华文行楷",30,true,true));
        btn[i].setFlat(true);
        btn[i].setStyleSheet("QPushButton:hover{color:red;font-size:60px} QPushButton{color:gray}");
    }
    btn[0].move(249,657);
    btn[1].move(btn[0].x()+350,btn[0].y());
    btn[2].move(btn[0].x()+700,btn[0].y());
    connect(&btn[0],&QPushButton::clicked,this,&Welcome::accept);
    connect(&btn[2],&QPushButton::clicked,this,&Welcome::close);
    connect(&btn[1],&QPushButton::clicked,this,&Welcome::OpenConfig);
}

void Welcome::OpenConfig()
{
//    config->setFixedSize(this->size());
//    config->setWindowTitle("游戏设置");
//    config->setCursor(QCursor(QPixmap(":/map_image/element/Cursor.png")));
//    config->setWindowIcon(QIcon(":/map_image/element/TankICO.ico"));

//    config->exec();
}

Welcome::~Welcome(){

}
